package kr.pe.xissy.soulmate.service;

import org.springframework.data.keyvalue.redis.core.HashOperations;
import org.springframework.data.keyvalue.redis.core.ListOperations;
import org.springframework.data.keyvalue.redis.core.SetOperations;
import org.springframework.data.keyvalue.redis.core.StringRedisTemplate;
import org.springframework.data.keyvalue.redis.core.ValueOperations;
import org.springframework.data.keyvalue.redis.core.ZSetOperations;
import org.springframework.stereotype.Service;

@Service
public abstract class SoulMateService {

	protected StringRedisTemplate redisTemplate;

	protected ValueOperations<String, String> valueOperations;
	protected ListOperations<String, String> listOperations;
	protected SetOperations<String, String> setOperations;
	protected ZSetOperations<String, String> zSetOperations;
	protected HashOperations<String, String, String> hashOperations;

	private final String KEY_STRING_PREFIX = "soulmate:";

	public SoulMateService(StringRedisTemplate redisTemplate) {
		this.redisTemplate = redisTemplate;

		valueOperations = redisTemplate.opsForValue();
		listOperations = redisTemplate.opsForList();
		setOperations = redisTemplate.opsForSet();
		zSetOperations = redisTemplate.opsForZSet();
		hashOperations = redisTemplate.opsForHash();
	}

	protected String getKeyStringPrefix() {
		return KEY_STRING_PREFIX;
	}

}
